package course;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class MyMap2 {
    public static void main(String[] args) {
        Map<String,String> map = new HashMap<>();

        //v put(K key, V value)  添加元素
        map.put("heima001","小智");
        map.put("heima002","小美");
        map.put("heima003","大胖");
        map.put("heima004","小黑");
        map.put("heima005","大师");

//        Set<String> set = map.keySet();
//        Iterator<String> it = set.iterator();
//        while (it.hasNext()){
//            String key = it.next();
//            String value = map.get(key);
//            System.out.println(key+"..."+value);
//        }
        Set<Map.Entry<String,String>> set = map.entrySet();
        Iterator<Map.Entry<String,String>> it = set.iterator();
        while (it.hasNext()){
            Map.Entry<String,String> entry = it.next();
            String key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key+"..."+value);
        }

        System.out.println("-------------------");

//        for (String key : set) {
//            String value = map.get((key));
//            System.out.println(key+"..."+value);
//        }

        for (Map.Entry<String, String> entry : set) {
            System.out.println(entry.getKey()+"..."+entry.getValue());
        }
    }
}
